﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        
        {
            Text1();
        }



        static void Text()
        {

            int[,] arr = new int[9,9];
            for (int i = 1; i <=arr.GetLength(1); i++)
            {
                for (int j = 1; j <= i; j++)
                {
                    Console.Write(j + "*" + i + "=" + j * i + "\t");

                }
                Console.WriteLine();
            }
        } //乘法表
        static void Text1()
        {

            Console.WriteLine("请输入正方形的边长:");
            int a = int.Parse(Console.ReadLine());

            for (int i = 1; i <= a; i++)
            {
                for (int j = 1; j <= a; j++)
                {
                    Console.Write("*" + " ");
                }
                Console.WriteLine();
            }



        } //正方形
        static void Text2()
        {
            Console.WriteLine("请输入正方形的边长:");
            int a = int.Parse(Console.ReadLine());

            string[,] arr = new string[a, a];

            for (int i = 0; i <arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    arr[i,j]= "*";
                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (i==0||j==0||i== arr.GetLength(0)-1||j== arr.GetLength(1)-1)
                    {
                        Console.Write(arr[i,j]);
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }

            //for (int i = 1; i <= a; i++)
            //{
            //    for (int j = 1; j <= a; j++)
            //    {
            //        if (j == 1 || j == a || i == 1 || i == a)
            //        {
            //            Console.Write("* ");
            //        }
            //        else
            //        {
            //            Console.Write("  ");
            //        }


            //    }
            //    Console.WriteLine();

            //}

        }//空心
        static void Text3()
        {
            //如果一个数组保存元素是有序的（从大到小），
            //向这个数组中插入一个数，使得插入后的数组元素仍然保持有序。

            int[] arr = new int[6];
            arr[0] = 100;
            arr[1] = 90;
            arr[2] = 60;
            arr[3] = 45;
            arr[4] = 31;

            Console.Write("原数组：");
            for (int i = 0; i < arr.Length; i++)
            {
                if (i == 5)
                {

                }
                else
                {
                    Console.Write(arr[i] + " ");
                }


            }
            Console.WriteLine();
            Console.WriteLine("请输入一个数：");
            int a = int.Parse(Console.ReadLine());
            arr[5] = a;

            Array.Sort(arr);
            Array.Reverse(arr);
            Console.WriteLine("排序后: ");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + " ");
            }

        }//数组排序
        static void Text4()
        {
            String[][] arr = new string[6][];
            arr[0] = new string[] { "1" };
            arr[1] = new string[] { "1" + " " + "1" };
            arr[2] = new string[] { "1" + " " + "2" + " " + "1" };
            arr[3] = new string[] { "1" + " " + "3" + " " + "3" + " " + "1" };
            arr[4] = new string[] { "1" + " " + "4" + " " + "6" + " " + "4" + " " + "1" };
            arr[5] = new string[] { "1" + " " + "5" + " " + "10" + " " + "10" + " " + "5" + " " + "1" };

            for (int i = 0; i < arr.Length; i++)
            {
                for (int j = 0; j < arr[i].Length; j++)
                {
                    Console.WriteLine(arr[i][j]);
                }
            }

        }//三角形
        static void Text5()
        {
            //  在 Main 方法中创建一个字符串类型的数组，并存入 5 个值，
            //  然后将数组中下标是偶数的元素输出。

            int[] arr = new int[5];
            arr[0] = 22;
            arr[1] = 1;
            arr[2] = 9;
            arr[3] = 4;
            arr[4] = 8;


            Console.WriteLine("数组的元素有：");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + " ");

            }
            Console.WriteLine();
            Console.WriteLine("下标是偶数的有：");
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] % 2 == 0)
                {
                    Console.Write(arr[i] + " ");
                }
            }

        } 

    }

}
